﻿using System;
using System.Collections.Generic;
using System.Text;

namespace KaiXin001er.Objects
{
    [Serializable]
    public class MatchInfo
    {
        /// <summary>
        /// 拉力赛第一组用户们的ID
        /// </summary>
        private List<string> _firstUserIDs;

        public List<string> FirstUserIDs
        {
            get { if (_firstUserIDs == null)_firstUserIDs = new List<string>(); return _firstUserIDs; }
        }
        /// <summary>
        /// 拉力赛第二组用户们的ID
        /// </summary>
        private List<string> _secondUserIDs;

        public List<string> SecondUserIDs
        {
            get { if (_secondUserIDs == null)_secondUserIDs = new List<string>();return _secondUserIDs; }
        }
        
        public MatchInfo()
        {
        }
        private string _firstUserString;

        public string FirstUserString
        {
            get { return _firstUserString; }
            set { _firstUserString = value; }
        }
        private string _secondUserString;

        public string SecondUserString
        {
            get { return _secondUserString; }
            set { _secondUserString = value; }
        }
        private string _dayString;

        public string DayString
        {
            get { return _dayString; }
            set { _dayString = value; }
        }

        private string _matchID;

        public string MatchID
        {
            get { return _matchID; }
            set { _matchID = value; }
        }
        private string _matchUid;

        public string MatchUid
        {
            get { return _matchUid; }
            set { _matchUid = value; }
        }
        private string _verifyCode;

        public string VerifyCode
        {
            get { return _verifyCode; }
            set { _verifyCode = value; }
        }
        /// <summary>
        /// 是否有我参赛
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public bool hasMyTeam(Account a)
        {
            
            foreach (string s in FirstUserIDs)
            {
                if (s == a.PlayerID) return true;
            }
            foreach (string s in SecondUserIDs)
            {
                if (s == a.PlayerID) return true;
            }
            return false;
        }
        public bool firstIsFriend(Account a)
        {
            foreach (string s in FirstUserIDs)
            {
                Friend f = a.FindFriendByID(s);
                if (f != null) return true;
            }
            return false;
        }
        public bool secondIsFriend(Account a)
        {
            foreach (string s in SecondUserIDs)
            {
                Friend f = a.FindFriendByID(s);
                if (f != null) return true;
            }
            return false;
        }
    }
}
